package com.xxx.client.android.db;

import android.content.ContentValues;
import android.database.Cursor;

public class HistoryDatabaseBuilder extends DatabaseBuilder<History> {

	@Override
	public History build(Cursor query) {
		int columnHistoryId = query.getColumnIndex("history_id");
		int columnHistoryName = query.getColumnIndex("history_name");
		int columnHistoryUrl = query.getColumnIndex("history_url");
		int columnHistoryTpye = query.getColumnIndex("history_type");

		History history = new History();
		history.setHistoryId(query.getInt(columnHistoryId));
		history.setHistoryName(query.getString(columnHistoryName));
		history.setHistoryUrl(query.getString(columnHistoryUrl));
		history.setHistoryType(query.getInt(columnHistoryTpye));
		return history;
	}

	@Override
	public ContentValues deconstruct(History history) {
		ContentValues values = new ContentValues();
		values.put("history_name", history.getHistoryName());
		values.put("history_url", history.getHistoryUrl());
		values.put("history_type", history.getHistoryType());
		return values;
	}

}
